<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="format-detection" content="telephone=no, email=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <script>
        function Sort(array) {
            var length = array.length;
            for (var i = 0; i < length - 1; i++) {
                //i代表已经排序好的序列最后一项下标
                var insert = array[i+1];
                var index = i + 1;//记录要被插入的下标
                for (var j = i; j >= 0; j--) {
                    if (insert < array[j]) {
                        //要插入的项比它小，往后移动
                        array[j+1] = array[j];
                        index = j;
                    }
                }
                array[index] = insert;
            }
            return array;
        }

        var arr = [100,90,80,62,80,8,1,2,39];
        var result = Sort(arr);
        console.log(result);
    </script>
</head>
<body>

</body>

</html>